package com.niit.main;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.niit.entity.Student;
import com.niit.util.MybatisUtil;

/**
 ** 根据姓名列关键字查询学生列表
 * <br>模糊查询：根据姓名列，查询包含指定关键字的学生的列表，如姓名包含“文”这个关键字的学生
 *
 * @author hanliang
 */
public class Test06_getByNamekeywords {

    public static void main(String[] args) {
        
        String keyword="文";
        List<Student> list = null;
        
    	try (SqlSession session = MybatisUtil.openSession()) {
			list = session.selectList(
					"getStudentListByNameKeyword",
					keyword);
		}

		System.out.println("-------------------------------------------------------------------------------------------");
		System.out.println("学号\t\t姓名\t\t密码\t\t性别\t班级");
		System.out.println("-------------------------------------------------------------------------------------------");
        
        for (Student s : list) {
            System.out.println(s);
        }
    }
}
